using System;
using UnityEngine;

public static class tk2dButtonExtensionsForAudioObserver
{
	public static AudioObserver RegisterAudioObserver(this tk2dButton button, AudioClip buttonPressedSound)
	{
		if (null == button.buttonPressedSound && null != buttonPressedSound)
		{
			button.buttonPressedSound = buttonPressedSound;
		}
		if (null == button.GetComponent<AudioSource>())
		{
			button.gameObject.AddComponent<AudioSource>();
		}
		AudioObserver audioObserver = button.GetComponent<AudioObserver>();
		if (null == audioObserver)
		{
			audioObserver = button.gameObject.AddComponent<AudioObserver>();
		}
		return audioObserver;
	}
}
